# Stat model 4: Adjusted by relatedness, rank, and sampling effortsrm_1 <-cmdstan_model("./stan_models/04/rel_rank.stan")m1 <- srm_1$sample(data = d,iter_warmup =2e3,iter_sampling =2e3,chains =4,parallel_chains =4 ) m1$summary() %>%saveRDS("./fitted_models/05/rel_rank_sum.rds")m1$draws() %>%saveRDS("./fitted_models/05/rel_rank_draws.rds")m1 <- m1 %>%tidy_draws() m1 %>%saveRDS("./fitted_models/05/rel_rank.rds")# Stat model 4 as well, with expected values as transformed parameterssrm_2 <-cmdstan_model("./stan_models/04/rel_rank_tp.stan")m1.2<- srm_2$sample(data = d,iter_warmup =2e3,iter_sampling =2e3,chains =4,parallel_chains =4 ) %>%tidy_draws()m1.2%>%saveRDS("./fitted_models/05/rel_rank_tp.rds")# Stat model 4': Adjusted by relatedness, rank, sampling effort, and groupsrm_3 <-cmdstan_model("./stan_models/04/grp_rel_rank.stan")m2 <- srm_3$sample(data = d,iter_warmup =2e3,iter_sampling =2e3,chains =4,parallel_chains =4 ) %>%tidy_draws()m2 %>%saveRDS("./fitted_models/05/grp_rel_rank.rds")
3.2 Marginal posteriors
Import posterior draws and plot them. First, the marginal posterior distribution of the fixed effects:
# Not stratified by group size (stat model 4)m1 <-readRDS("./fitted_models/05/rel_rank.rds")m1 %>%fp(limo =c(-3.2, 2.5),vec_param =c("D", "b_Re", "b_Ra[2]", "b_Ra[1]"))
# Stratified by group size (stat model 4')m2 <-readRDS("./fitted_models/05/grp_rel_rank.rds")m2 %>%fp(limo =c(-3.2, 2.1),vec_param =c("b_Re", "b_Ra[1]", "b_Ra[2]", "d[1]", "d[2]", "d[3]"))
3.3\(\psi_{[a, b]}\)
\(\psi_{[a, b]}\) is a transformed parameter. It is defined as: \[
\psi_{[a, b]} =
D +
G_{[a]} +
R_{[b]} +
T_{[a, b]}
\]
We show the distribution of \(\psi_{[a, b]}\)’s posterior means:
Show code:
# Extract expected valuesm1.2<-readRDS("./fitted_models/05/rel_rank_tp.rds")# Posterior meanspsi <- m1.2%>%select(starts_with("psi")) %>%gather(param, value) %>%group_by(param) %>%summarise(value =mean(value)) %>%pull(value)# 10, 50, and 90% percentilespsi_hat <- psi %>%quantile(c(.1, .5, .9))# Plotpsi %>%hist.plot(binw =0.2, fill ="#c4bcaf", linewidth =0.5) +ylim(c(-2, 100)) +geom_point(data =tibble(y =0.2, x = psi_hat), aes(x = x, y = y), col ="white", fill ="#37807e", size =3, pch =21)
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
3.4 Posterior estimates for relatedness
CATE for three baselines \(\psi\).
# Contrasts for the three psi a <- (exp(psi_hat[1] + m1$b_Re) -exp(psi_hat[1])) b <- (exp(psi_hat[2] + m1$b_Re) -exp(psi_hat[2])) c <- (exp(psi_hat[3] + m1$b_Re) -exp(psi_hat[3]))
1.2 Social network
(Not displayed in the HTML doc)
Show code: